﻿// Jinx AJAX Framework
// Copyright (C) 2008 Blake Hegerle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;

namespace Jinx.Utility.Logging
{
    public class ConsoleLogger : ILogger
    {
        #region ILogger Members

        public void Fatal(string Message, params object[] Params)
        {
            Log("FATAL", Message, Params);
        }

        public void Fatal(Exception Exception, string Message, params object[] Params)
        {
            Log("FATAL", Exception, Message, Params);
        }

        public void Fatal(Exception Exception)
        {
            Log("FATAL", Exception);
        }

        public void Error(string Message, params object[] Params)
        {
            Log("ERROR", Message, Params);
        }

        public void Error(Exception Exception, string Message, params object[] Params)
        {
            Log("ERROR", Exception, Message, Params);
        }

        public void Error(Exception Exception)
        {
            Log("ERROR", Exception);
        }

        public void Warn(string Message, params object[] Params)
        {
            Log("WARN", Message, Params);
        }

        public void Warn(Exception Exception, string Message, params object[] Params)
        {
            Log("WARN", Exception, Message, Params);
        }

        public void Warn(Exception Exception)
        {
            Log("WARN", Exception);
        }

        public void Info(string Message, params object[] Params)
        {
            Log("INFO", Message, Params);
        }

        public void Info(Exception Exception, string Message, params object[] Params)
        {
            Log("INFO", Exception, Message, Params);
        }

        public void Info(Exception Exception)
        {
            Log("INFO", Exception);
        }

        public void Debug(string Message, params object[] Params)
        {
            Log("DEBUG", Message, Params);
        }

        public void Debug(Exception Exception, string Message, params object[] Params)
        {
            Log("DEBUG", Exception, Message, Params);
        }

        public void Debug(Exception Exception)
        {
            Log("DEBUG", Exception);
        }

        public void Trace(string Message, params object[] Params)
        {
            Log("TRACE", Message, Params);
        }

        public void Trace(Exception Exception, string Message, params object[] Params)
        {
            Log("TRACE", Exception, Message, Params);
        }

        public void Trace(Exception Exception)
        {
            Log("TRACE", Exception);
        }

        #endregion

        private void Log(string Severity, string Message, object[] Params)
        {
            Console.WriteLine(Severity + ": " + Message, Params);
        }

        private void Log(string Severity, Exception Exception, string Message, params object[] Params)
        {
            Console.WriteLine(Severity + ": " + Exception.Message + " - " + Message, Params);
        }

        private void Log(string Severity, Exception Exception)
        {
            Console.WriteLine(Severity + ": " + Exception.Message);
        }
    }
}